package com.guchenbo.bigdata.spark;

import org.apache.spark.api.java.function.FilterFunction;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.SparkSession;

/**
 * @author guchenbo
 */
public class SparkDemo {

    public static void main(String[] args) {
        String path = args[1];
        SparkSession sparkSession = SparkSession.builder().appName("spark demo")
                        .master(args[0]).getOrCreate();
        Dataset<String> ds = sparkSession.read().textFile(path);

        long n1 = ds.filter((FilterFunction<String>) s -> s.contains("a")).count();
        System.out.println("file contains a count: " + n1);
        sparkSession.stop();
    }
}
